export function deepClone(source) {
  if (!source && typeof source !== 'object') {
    throw new Error('error arguments', 'deepClone')
  }
  const targetObj = source.constructor === Array ? [] : {}
  Object.keys(source).forEach(keys => {
    if (source[keys] && typeof source[keys] === 'object') {
      targetObj[keys] = deepClone(source[keys])
    } else {
      targetObj[keys] = source[keys]
    }
  })
  return targetObj
}



export function ParamToObj(url) {
  let qs, obj = {}
  if (url.indexOf('?') != -1) {
    qs = url.split('?')[1].split('&').filter(i => i)
    qs.forEach(item => {
      let sp = item.split('=')
      obj[[sp[0]]] = sp[1]
    })
  }
  return obj
}

export function ObjToParam(data = {}) { //解析参数
  if (typeof data == "object") {
    return Object.entries(data).map((t,i)=>(`${i ? '&' : ''}${t[0]}=${t[1]}`)).join('')
  }
  return ''
}

